﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <div class="layui-form-item">
        <button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl" onclick="Addinit()">新增</button>
    </div>
    <br />
    <h3>基本信息</h3>
    <br />
    <hr />

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">

                <table>
                    <tr>
                        
                        <td>

                            <div class="layui-inline">
                                <label class="layui-form-label">品种</label>
                                <div class="layui-input-block">
                                    <select id="recordBreed" lay-filter="testSelect">
                                        <option value="">请选择品种</option>
                                        <option value="杜泊">杜泊</option>
                                        <option value="澳洲白">澳洲白</option>
                                        <option value="湖羊">湖羊</option>
                                        <option value="黑头杜泊">黑头杜泊</option>
                                        <option value="杜湖">杜湖</option>
                                        <option value="澳湖">澳湖</option>
                                        <option value="澳杜湖">澳杜湖</option>
                                        <option value="杜杜湖">杜杜湖</option>
                                        <option value="萨杜湖">萨杜湖</option>
                                    </select>
                                </div>
                            </div>

                        </td>
                    </tr>

                    <tr>
                        <td>

                            <div class="layui-form-item">
                                <label class="layui-form-label">电子耳标号</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="recordCorpuscle" lay-verify="required" autocomplete="off" lay-reqtext="请输入电子耳标号" lay-affix="clear" class="layui-input demo-phone">
                                </div>
                            </div>

                        </td>

                        <td>

                            <div class="layui-inline">
                                <label class="layui-form-label">基因等级</label>
                                <div class="layui-input-block">
                                    <select id="gene" lay-filter="testSelect">
                                        <option value="">请选择基因等级</option>
                                        <option value="后备级">后备级</option>
                                        <option value="核心级">核心级</option>
                                        <option value="生产级">生产级</option>
                                        <option value="未定级">未定级</option>
                                    </select>
                                </div>
                            </div>

                        </td>
                    </tr>
                </table>

                <h3>出生信息</h3>
                <br />
                <hr />

                <table>
                    <tr>
                        <td>

                            <div class="layui-inline">
                                <label class="layui-form-label">父亲耳号</label>
                                <div class="layui-input-block">
                                    <select id="recordFather" lay-filter="testSelect">
                                        <option value="">请选择父亲耳号</option>
                                        <option value="gyz08">gyz08</option>
                                        <option value="hsc55">hsc55</option>
                                        <option value="art62">art62</option>
                                    </select>
                                </div>
                            </div>

                        </td>

                        <td>

                            <div class="layui-inline">
                                <label class="layui-form-label">母亲耳号</label>
                                <div class="layui-input-block">
                                    <select id="recordMother" lay-filter="testSelect">
                                        <option value="">请选择母亲耳号</option>
                                        <option value="NX009">NX009</option>
                                        <option value="ND202">ND202</option>
                                        <option value="SC522">SC522</option>
                                    </select>
                                </div>
                            </div>

                        </td>

                        <td>

                            <label class="layui-form-label">出生日期</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="recordDate" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>

                        </td>

                    </tr>

                    <tr>
                        <td>

                            <label class="layui-form-label">入场日期</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="admissionDate" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>

                        </td>

                        <td>

                            <div class="layui-inline">
                                <label class="layui-form-label">出生场地</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="recordSite" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                                </div>
                            </div>

                        </td>

                        <td>

                            <div class="layui-inline">
                                <label class="layui-form-label">出生重（公斤）</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="recordWeight" lay-verify="required" autocomplete="off" lay-reqtext="请输入用户名" lay-affix="clear" class="layui-input demo-phone">
                                </div>
                            </div>

                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="layui-inline">
                                <label class="layui-form-label">备注</label>
                                <textarea id="RecordRemark" placeholder="请选择" class="layui-textarea"></textarea>
                            </div>
                        </td>

                    </tr>

                </table>

            </div>

        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
    <script>
        layui.use(['table'], function () {
            var table = layui.table;
            var form = layui.form;
            var layer = layui.layer;

        });
    </script>
</body>
</html>

<script>
   
    function Addinit() { 
        var data = {
            recordBreed: $("#recordBreed").val(),
            recordCorpuscle: $("#recordCorpuscle").val(),
            gene: $("#gene").val(),
            recordFather: $("#recordFather").val(),
            recordMother: $("#recordMother").val(),
            recordDate: $("#recordDate").val(),
            admissionDate: $("#admissionDate").val(),
            recordSite: $("#recordSite").val(),
            recordWeight: $("#recordWeight").val(),
            recordRemark: $("#recordRemark").val(),
            recordType: 0,
            farmId: localStorage["farmId"]
        }
        
        $.ajax({
            url: "http://localhost:5269/api/SheepArchive/SheepArchivesCreate",
            type: 'post',
            data: JSON.stringify(data),
            dataType: "json",
            contentType: "application/json",
            success: res => {
                if (res.code == 0) {
                    layer.msg('添加成功')
                }
                else {
                    layer.msg('保存失败')
                }
            }
        })
    }

</script>